package com.ztesoft.report.service;


import com.github.pagehelper.PageInfo;
import com.ztesoft.report.base.pojo.R;
import com.ztesoft.report.base.service.BaseService;
import com.ztesoft.report.engine.data.ReportDataSource;
import com.ztesoft.report.engine.data.ReportMetaDataColumn;
import com.ztesoft.report.engine.data.ReportQueryParamItem;
import com.ztesoft.report.engine.options.QueryParameterOptions;
import com.ztesoft.report.engine.options.ReportOptions;
import com.ztesoft.report.entity.Report;
import com.ztesoft.report.entity.ReportDto;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 报表信息表 服务类
 * </p>
 *
 * @author y3tu
 * @since 2018-05-29
 */
public interface ReportService extends BaseService<Report> {
    /**
     * @param page
     * @param fieldName
     * @param categoryId
     * @return
     */
    List<Report> getByPage(PageInfo page, String fieldName, Integer categoryId);

    /**
     * @param id
     * @param json
     * @return
     */
    boolean saveQueryParams(int id, String json);

    /**
     * @param uid
     * @return
     */
    Report getByUid(String uid);

    /**
     * @param id
     * @return
     */
    String getSqlText(int id);

    /**
     * @param dsId
     * @param sqlText
     * @return
     */
    List<ReportMetaDataColumn> getMetaDataColumns(int dsId, String sqlText);

    /**
     * @param dsId
     * @param sqlText
     */
    void explainSqlText(int dsId, String sqlText);

    /**
     * @param dsId
     * @param sqlText
     * @return
     */
    List<ReportMetaDataColumn> executeSqlText(int dsId, String sqlText);

    /**
     * @param dsId
     * @param sqlText
     * @return
     */
    List<ReportQueryParamItem> executeQueryParamSqlText(int dsId, String sqlText);

    /**
     * 解析json格式的报表元数据列为ReportMetaDataColumn对象集合
     *
     * @return List<ReportMetaDataColumn>
     */
    List<ReportMetaDataColumn> parseMetaColumns(String json);

    /**
     * 解析json格式的报表查询参数为QueryParameter对象集合
     *
     * @return List<QueryParameterOptions>
     */
    List<QueryParameterOptions> parseQueryParams(String json);

    /**
     * 解析json格式的报表选项ReportOptions
     *
     * @return ReportOptions
     */
    ReportOptions parseOptions(String json);

    /**
     * @param dsId
     * @return
     */
    ReportDataSource getReportDataSource(int dsId);

    Map addReport(ReportDto po);

    Map updateReport(ReportDto po);

    Map previewReport(ReportDto po);

    R searchMidBill(Map map);


    void valueParseByConvertType(ReportDto po, List<Map> list);

    Object queryMid(StringBuilder sql,Map<String,Object> map,int current,int size,int dsID,String header,String meta);
}
